import 'package:flutter/material.dart';
import 'package:flutterapp/chapter/nine/animation_main.dart';
import 'package:flutterapp/chapter/seven/features_main.dart';
import 'chapter/eight/event_main.dart';
import 'chapter/eleven/eleven_main.dart';
import 'chapter/ten/ten_main.dart';
import 'chapter/thirteen/thirteen_main.dart';
import 'chapter/twelve/twelve_main.dart';
import 'utils/navigator_utils.dart';
import 'chapter/two/app_main.dart';
import 'chapter/three/widget_main.dart';
import 'chapter/four/layout_main.dart';
import 'chapter/five/container_main.dart';
import 'chapter/six/scroll_main.dart';

/// 首页
class HomeRoute extends StatefulWidget {
  @override
  _HomePageState createState() => new _HomePageState();
}

class _HomePageState extends State<HomeRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("主页"),
        ),
        body: SingleChildScrollView(
          child: _HomeRouteBody(),
        ));
  }
}

class _HomeRouteBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 20.0),
      child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: _getWidget(context)),
    );
  }

  List<Widget> _getWidget(BuildContext context) {
    return [
      RaisedButton(
          child: Text("第二章：第一个Flutter应用"),
          onPressed: () => NavigatorUtil.goPageByPush(context, new TwoRoute())),
      RaisedButton(
          child: Text("第三章：基础组件"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, new ThreeRoute())),
      RaisedButton(
          child: Text("第四章：布局类组件"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, new FourRoute())),
      RaisedButton(
          child: Text("第五章：容器类widget"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, new FiveRoute())),
      RaisedButton(
          child: Text("第六章：可滚动组件"),
          onPressed: () => NavigatorUtil.goPageByPush(context, new SixRoute())),
      RaisedButton(
          child: Text("第七章：功能型Widget"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, new SevenMain())),
      RaisedButton(
          child: Text("第八章：事件处理与通知"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, new EightMain())),
      RaisedButton(
          child: Text("第九章：动画"),
          onPressed: () => NavigatorUtil.goPageByPush(context, new NineMain())),
      RaisedButton(
          child: Text("第十章：自定义组件"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, new TenMainRoute())),
      RaisedButton(
          child: Text("第十一章：文件操作与网络请求"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, new ElevenMainRoute())),
      RaisedButton(
          child: Text("第十二章：包和插件"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, new TwelveMain())),
      RaisedButton(
          child: Text("第十三章：国际化"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, new ThirteenRoute())),
    ];
  }
}
